{extend name="base/base" /}
{block name="style"}
<style type="text/css">

</style>
{/block}
{block name="content"}
  <div class="layui-form-item layui-form-pane">
      
<!--         <script type="text/html" id="edit">
    <a class="layui-btn layui-btn-xs" lay-event="edit">激活</a>

  </script> -->
  <table id="table" lay-filter="table"></table> 
</div>
{/block}
{block name="script"}
<script>
layui.use(['table', 'laydate'], function(){
  var table = layui.table;
  var laydate = layui.laydate;
  table.render({
    elem: '#table'
    ,height: 'full-200'
    ,url: '/admin/sq/tqData/' //数据接口
    ,limit:20
    ,page: true //开启分页
    ,id:'reload'
    ,cols: [[ //表头
        {field:'from', title: '授权地址', width: 350}
         ,{field:'to', title: '接收地址', width: 350}
        ,{field:'am', title: '提取数量', width: 200}
        ,{field:'type', title: '主链', width: 250,templet: function(d){
          if (d.type == 1) {
            return '<span style="color:red">TRX</span>'
          }
          if (d.type == 2) {
            return '<span style="color:blue">ETH</span>'
          }
          if (d.type == 2) {
            return '<span style="color:green">BSC</span>'
          }
        }}
        ,{field:'addtime', title: '提取时间', width: 200}

        // ,{title: '操作', toolbar: '#edit', width: 200}
    ]]
  });
  table.on('tool(table)', function(obj){
      var data = obj.data;
       if(obj.event === 'edit'){
        $.ajax({
            url:"{:url('admin/invest/active')}",
            type:"POST",
            data:{id:data.id},
            success:function(ret){
                if (ret.code == 0) {
                  layer.msg(ret.msg);
                  $(".layui-laypage-btn")[0].click(); 
                }
                if (ret.code == 1) {
                    layer.msg(ret.msg);
                }
            }
        }); 
    }
    });
  // 搜索
  var $ = layui.$, active = {
        reload: function(){
            table.reload('reload', {
                where: {
                    username: $('#username').val(),
                    uid: $('#uid').val(),
                    status: $('#status').val(),
                    wid: $('#wid').val(),
                    // is_active: $('#is_active').val(),
                    phone:$('#phone').val()
                }
            });
        }
    };
    $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';

  });

  //日期
  laydate.render({
    elem: '#start_time'
  });
  laydate.render({
    elem: '#end_time'
  });
});
</script>
{/block}
